# Maintainer: Dominic Sisneros <dsisnero@gmail.com>

_realname=lasem
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.6.0
pkgrel=4
pkgdesc="SVG and MathML rendering library. (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/LasemProject/lasem"
license=('spdx:LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-pango")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             "${MINGW_PACKAGE_PREFIX}-gi-docgen"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-gtk4")
optdepends=("${MINGW_PACKAGE_PREFIX}-gtk4: lsm-viewer")
source=("https://github.com/LasemProject/lasem/releases/download/${pkgver}/${_realname}-${pkgver}.tar.xz")
sha256sums=('991a23debf7e2c5683516d7a90eca112a9c985252e984d0e3410691d7e1159ea')

prepare() {
  cd "${_realname}-${pkgver}"
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    meson \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      -Dintrospection=enabled \
      -Ddocumentation=enabled \
      -Dviewer=enabled \
      ../${_realname}-${pkgver}

  meson compile
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  meson test
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  DESTDIR="${pkgdir}" meson install

  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
